import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '名称',
    align:"center",
    dataIndex: 'name'
   },
   {
    title: '类型',
    align:"center",
    dataIndex: 'type_dictText'
   },
   {
    title: '描述',
    align:"center",
    dataIndex: 'remark'
   },
   {
    title: '引用标识',
    align:"center",
    dataIndex: 'quote_dictText'
   },
   {
    title: '标签',
    align:"center",
    dataIndex: 'labels'
   },
   {
    title: '状态',
    align:"center",
    dataIndex: 'states_dictText'
   },
   {
    title: '排序',
    align:"center",
    sorter: true,
    dataIndex: 'sort'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "名称",
      field: 'name',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "类型",
      field: 'type',
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"m_resource_type"
      },
      //colProps: {span: 6},
 	},
	{
      label: "描述",
      field: 'remark',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "标签",
      field: 'labels',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "状态",
      field: 'states',
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"valid_status"
      },
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '名称',
    field: 'name',
    component: 'Input',
  },
  {
    label: '类型',
    field: 'type',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"m_resource_type"
     },
  },
  {
    label: '描述',
    field: 'remark',
    component: 'InputTextArea',
  },
  {
    label: '引用标识',
    field: 'quote',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"yn"
     },
  },
  {
    label: '标签',
    field: 'labels',
    component: 'Input',
  },
  {
    label: '状态',
    field: 'states',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"valid_status"
     },
  },
  {
    label: '排序',
    field: 'sort',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: false},
                 { pattern: /^-?\d+$/, message: '请输入整数!'},
          ];
     },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  name: {title: '名称',order: 0,view: 'text', type: 'string',},
  type: {title: '类型',order: 1,view: 'list', type: 'string',dictCode: 'm_resource_type',},
  remark: {title: '描述',order: 2,view: 'textarea', type: 'string',},
  quote: {title: '引用标识',order: 3,view: 'radio', type: 'string',},
  labels: {title: '标签',order: 4,view: 'text', type: 'string',},
  states: {title: '状态',order: 5,view: 'radio', type: 'string',},
  sort: {title: '排序',order: 6,view: 'text', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}